package lion.blog.tag;

import java.util.Iterator;
import java.util.List;

import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.jstl.core.LoopTagSupport;

import lion.blog.model.BlogCatelog;
import lion.blog.service.BlogService;
import lion.framework.core.bean.BeanFactory;

/**
 * 
 * 分类列表
 * 
 * @author lion
 * @email hl_0074@sina.com
 * @date 2015年8月28日
 */
public class CatelogListTag extends LoopTagSupport {

	private static final long serialVersionUID = -5804092548280857511L;

	private Iterator<BlogCatelog> items;

	@Override
	protected boolean hasNext() throws JspTagException {

		return items.hasNext();
	}

	@Override
	protected Object next() throws JspTagException {

		return items.next();
	}

	@Override
	protected void prepare() throws JspTagException {

		BlogService service = BeanFactory.getBeanFactory(BeanFactory.PLATFORM_BEAN_FACTORY).get("blog.BlogService");

		List<BlogCatelog> catelogs = service.getBlogCatelogs();

		items = catelogs.iterator();
	}
}
